package com.xinghou.platform.file.chain.command.voice;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;

import com.xinghou.platform.file.model.ResourceContext;
import com.xinghou.platform.file.service.UpphotoService;
import com.xinghou.platform.util.AppContextUtil;
import com.xinghou.platform.util.ConfigUtil;
import com.xinghou.platform.util.StringUtils;

/**
 * 
 * @author wzk
 *
 */
public class VoiceDataProcessCommand implements Command{

	private UpphotoService upphotoService;
	
	@Override
	public boolean execute(Context context) throws Exception {
		@SuppressWarnings("unchecked")
		ResourceContext<byte[], String> resourceContext = (ResourceContext<byte[], String>)context;

		Map<String, String> result = new HashMap<String, String>();
		result.put("voicename", resourceContext.getSource().getResourceName());
		result.put("voiceurl", resourceContext.getExtars()[0].getSubPath().replace("\\", "/"));
		result.put("userid", resourceContext.getRequest().getUserId());
		result.put("time", resourceContext.getRequest().getTime());
		
		//更新语音数据
		int pid=0;
		upphotoService = (UpphotoService)AppContextUtil.getBean("upphotoService");
		
		result.put("touserid", resourceContext.getRequest().getTouserid());
		pid = upphotoService.addVoiceMsgData(result);
		context.put("pid",pid);
		return false;
	}


}
